#ifndef PLAYER_H
#define PLAYER_H

#include <QObject>
class QTcpSocket;

#include "core/global.h"

class Player: public QObject
{
    Q_OBJECT

    Q_PROPERTY(int player_id READ getPlayerId WRITE setPlayerId)
    Q_PROPERTY(QString player_name READ getPlayerName WRITE setPlayerName)
    Q_PROPERTY(QString phase READ getPhaseString WRITE setPhaseString)
    Q_PROPERTY(bool is_ready READ isReady WRITE setReady)
    Q_PROPERTY(bool is_hosted READ isHosted WRITE setHosted)

public:
    enum Phase{Start, Playing, End, Inactive};

    Player();

    int getPlayerId() const;
    void setPlayerId(int id);

    QString getPlayerName() const;
    void setPlayerName(const QString &name);

    Phase getPhase() const;
    void setPhase(Phase phase);
    QString getPhaseString() const;
    void setPhaseString(const QString &phase_str);

    bool isReady() const;
    void setReady(bool ready);

    bool isHosted() const;
    void setHosted(bool ready);

    void fromString(const QString &str);
    QString toString() const;

    void notify(CommandType command, const QString &data);
    void notify(CommandType command, const QByteArray &data);
    void notify(CommandType command);
    void notifyProperty(const char *key);

protected:
    int player_id;
    QString player_name;
    Phase phase;
    bool is_ready;
    bool is_hosted;
    QTcpSocket *socket;
};

#endif // PLAYER_H
